<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title>IM</title>
    <link rel="stylesheet" href="{{asset('/admin/js/rong/im.css') }}">

</head>
<body>

<div id="rcs_app"></div>

</body>

<script src="{{asset('/admin/js/jquery.min.js?v=12') }}"></script>
<script src="{{asset('/admin/js/common.js?v=13') }}"></script>
<script src="http://cdn.ronghub.com/RongIMLib-2.3.0.js"></script>
{{--<script src="{{asset('/admin/js/rong/RongIMLib-2.3.0.js') }}"></script>--}}
<script src="{{asset('/admin/js/rong/RongEmoji-2.2.6.min.js') }}"></script>
<script src="{{asset('/admin/js/rong/utils.js') }}"></script>
<script src="{{asset('/admin/js/rong/qiniu-upload.js') }}"></script>
<script src="{{asset('/admin/js/rong/template.js?v=126') }}"></script>
<script src="{{asset('/admin/js/rong/emoji.js') }}"></script>
<script src="{{asset('/admin/js/rong/aaim.js?v=113') }}"></script>


    <script>
        /*
        具体使用时：
        1：切换到自己的 key 和 token
        2：移除 aaim.js 里的 sendTextMessage(instance); 这行代码
        3：自行二次开发
        4：参考
            - 用户数据处理 http://support.rongcloud.cn/kb/NjQ5
            - 消息状态 http://support.rongcloud.cn/kb/NjMz
            - 集成指南 https://rongcloud.github.io/websdk-demo/integrate/guide.html
            - 其他 demo https://github.com/rongcloud/websdk-demo
        */
        (function(){

            var appKey = "pwe86ga5p9wp6";
            var token = '';
            var name = '';
            var head_img = '';

            jQuery.ajax({
                url: js_url('admin-get-platform_info'),
                type: 'get',
                async: false,
                dataType: "json",
                success: function (result) {
                    if (result.state === 0) {
                        token = result.data.data.token;
                        name = result.data.data.name;
                        head_img = result.data.data.head_img;
                    }
                }
            });
            RCS.init({
                appKey: appKey,
                token: token,
                name: name,
                head_img: head_img,
                target: document.getElementById('rcs_app'),
                showConversitionList: true,
                templates: {
                    button: ['<div class="rongcloud-consult rongcloud-im-consult">',
                        '   <button onclick="RCS.showCommon()"><span class="rongcloud-im-icon">未读消息数</span><span id="all_no_read_num"></span></button>',
                        '</div>',
                        '<div class="customer-service" style="display: none;"></div>'].join('')//"templates/button.html",
                }
            });
        })();


        // function aa() {
        //     RongIMClient.getInstance().getTotalUnreadCount({
        //         onSuccess: function(count) {
        //             if(count > 0){
        //                 $('#all_no_read_num')[0].innerHTML = count;
        //             }
        //             console.log('获取所有会话未读消息数成功', count);
        //         },
        //         onError: function(error) {
        //             console.log('获取所有会话未读消息数失败', error);
        //         }
        //     });
        // }
    </script>

</html>
